"use strict";

var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");

var _trim = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/trim"));

/**
 * 校验运单号是否正确
 * 方法说明：该正则来自于藏经阁apollo静态配置，目前暂不支持从藏经阁实时获取，后期版本会考虑支持。
 *
 * @since 0.0.6
 * @category 正则
 * @param {string|number} str 需要校验的字符串.
 * @param {object} config 配置参数.
 * @param {boolean} config.isDetail 是否返回详细信息, 为true时返回CheckResult, false时返回boolean 默认: false.
 *
 * @returns { boolean|CheckResult } 校验结果 或 结果对象.
 *
 * @typedef {object} CheckResult
 * @property {boolean} status 校验结果
 * @property {string} errorMsg 错误提示
 * @property {RexExp} reg 校验数据使用的RexExp对象
 *
 * @example
 *
 * z.isBillCode('73177973010263')
 * // => true
 *
 * z.isBillCode('73177973010263', {isDetail: true})
 * // { status: true, errorMsg: '', reg: /^((768|765|778|779|719|518|880|660|805|718|728|738|761|762|763|701|757|689|738|528)[0-9]{9})$|^2013[0-9]{8}$|^((8010|8021)[0-9]{6})$|^((a|b|h)[0-9]{13})$|^((5)[0-9]{9})$|^((80|88|89|90|91|92|93|94|95|96|97|99|200|21)[0-9]{8})$|^(90|91|94|53)[0-9]{10}$|^(120)[0-9]{9}$|^(23)[0-9]{8}$|^(780)[0-9]{9}$|^(881)[0-9]{9}$|^(6666666666)[0-9]{2}$|^54[0-9]{10}$|^(24)[0-9]{8}$|^(960)[0-9]{9}$|^665[0-9]{9}$|^(wx|hf)[0-9]{10}$|^(25)[0-9]{8}$|^(26)[0-9]{8}$|^(63|64)[0-9]{10}$|^(72)[0-9]{10}$|^(220|221|223|224|225|226|227|228|229)[0-9]{7}$|^3[0-9]{9}$|^731[0-9]{11}$|^73220[0-9]{9}$|^73200[0-9]{9}$|^7518[0-9]{8}$|^4[0-9]{9}$|^73210[0-9]{9}$|^771[0-9]{11}$|^733000[0-9]{8}$|^73211[0-9]{9}$|^5[0-9]{9}$|^(A)[0-9]{9}$|^C[0-9]{9}$|^D[0-9]{9}$|^781[0-9]{11}$|^(7)[0-9]{9}$|^73222[0-9]{9}$|^734[0-9]{11}$|^75210[0-9]{9}$|^73223[0-9]{9}$|^73224[0-9]{9}$|^8[0-9]{7}$|^100[0-9]{9}$|^118[0-9]{9}$|^128[0-9]{9}$|^688[0-9]{9}$|^68[0-9]{10}$|^882[0-9]{9}$|^9[0-9]{7}$|^010[0-9]{9}$|^628[0-9]{9}$|^E[0-9]{9}$|^F[0-9]{9}$|^G[0-9]{9}$|^H[0-9]{9}$|^7777[0-9]{10}$|^758[0-9]{11}$|^759[0-9]{11}$|^760[0-9]{11}$|^741[0-9]{11}$|^73226[0-9]{9}$|^777600[0-9]{8}$|^77761[0-9]{9}$|^73227[0-9]{9}$|^H[0-9]{9}$|^J[0-9]{9}$|^K[0-9]{9}$|^L[0-9]{9}$|^M[0-9]{9}$|^N[0-9]{9}$|^73225[0-9]{9}$|^31111[0-9]{9}$|^754[0-9]{11}$|^O[0-9]{9}$|^P[0-9]{9}$|^Q[0-9]{9}$|^R[0-9]{9}$|^S[0-9]{9}$|^T[0-9]{9}$|^755[0-9]{11}$|^73228[0-9]{9}$|^73229[0-9]{9}$|^782[0-9]{11}$|^756[0-9]{11}$|^U[0-9]{9}$|^V[0-9]{9}$|^W[0-9]{9}$|^X[0-9]{9}$|^Y[0-9]{9}$|^Z[0-9]{9}$|^[A-Z]{2}[0-9]{8}$|^766[0-9]{11}$/ }
 *
 */
function isBillCode(str) {
  var _context;

  var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
      _ref$isDetail = _ref.isDetail,
      isDetail = _ref$isDetail === void 0 ? false : _ref$isDetail;

  var rt = {
    status: false,
    errorMsg: ''
  }; // 校验正则

  rt.reg = new RegExp('^((768|765|778|779|719|518|880|660|805|718|728|738|761|762|763|701|757|689|738|528)[0-9]{9})$|^2013[0-9]{8}$|^((8010|8021)[0-9]{6})$|^((a|b|h)[0-9]{13})$|^((5)[0-9]{9})$|^((80|88|89|90|91|92|93|94|95|96|97|99|200|21)[0-9]{8})$|^(90|91|94|53)[0-9]{10}$|^(120)[0-9]{9}$|^(23)[0-9]{8}$|^(780)[0-9]{9}$|^(881)[0-9]{9}$|^(6666666666)[0-9]{2}$|^54[0-9]{10}$|^(24)[0-9]{8}$|^(960)[0-9]{9}$|^665[0-9]{9}$|^(wx|hf)[0-9]{10}$|^(25)[0-9]{8}$|^(26)[0-9]{8}$|^(63|64)[0-9]{10}$|^(72)[0-9]{10}$|^(220|221|223|224|225|226|227|228|229)[0-9]{7}$|^3[0-9]{9}$|^731[0-9]{11}$|^73220[0-9]{9}$|^73200[0-9]{9}$|^7518[0-9]{8}$|^4[0-9]{9}$|^73210[0-9]{9}$|^771[0-9]{11}$|^733000[0-9]{8}$|^73211[0-9]{9}$|^5[0-9]{9}$|^(A)[0-9]{9}$|^C[0-9]{9}$|^D[0-9]{9}$|^781[0-9]{11}$|^(7)[0-9]{9}$|^73222[0-9]{9}$|^734[0-9]{11}$|^75210[0-9]{9}$|^73223[0-9]{9}$|^73224[0-9]{9}$|^8[0-9]{7}$|^100[0-9]{9}$|^118[0-9]{9}$|^128[0-9]{9}$|^688[0-9]{9}$|^68[0-9]{10}$|^882[0-9]{9}$|^9[0-9]{7}$|^010[0-9]{9}$|^628[0-9]{9}$|^E[0-9]{9}$|^F[0-9]{9}$|^G[0-9]{9}$|^H[0-9]{9}$|^7777[0-9]{10}$|^758[0-9]{11}$|^759[0-9]{11}$|^760[0-9]{11}$|^741[0-9]{11}$|^73226[0-9]{9}$|^777600[0-9]{8}$|^77761[0-9]{9}$|^73227[0-9]{9}$|^H[0-9]{9}$|^J[0-9]{9}$|^K[0-9]{9}$|^L[0-9]{9}$|^M[0-9]{9}$|^N[0-9]{9}$|^73225[0-9]{9}$|^31111[0-9]{9}$|^754[0-9]{11}$|^O[0-9]{9}$|^P[0-9]{9}$|^Q[0-9]{9}$|^R[0-9]{9}$|^S[0-9]{9}$|^T[0-9]{9}$|^755[0-9]{11}$|^73228[0-9]{9}$|^73229[0-9]{9}$|^782[0-9]{11}$|^756[0-9]{11}$|^U[0-9]{9}$|^V[0-9]{9}$|^W[0-9]{9}$|^X[0-9]{9}$|^Y[0-9]{9}$|^Z[0-9]{9}$|^[A-Z]{2}[0-9]{8}$|^766[0-9]{11}$'); // 去除前后空格

  str = (0, _trim.default)(_context = String(str)).call(_context); // 正则

  if (!rt.reg.test(str)) {
    rt.errorMsg = '运单号非法';
  } else {
    rt.status = true;
  }

  return isDetail ? rt : rt.status;
}

module.exports = isBillCode;